﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TheLogWatcher
{
    public class PredefinedFormats
    {
        private static List<FormatSettings> formats = new List<FormatSettings>();
        public static List<FormatSettings> Formats
        {
            get
            {
                formats.Add(Log4jDE());
                formats.Add(Log4jEN());
                formats.Add(WindowsUpdateLog());
                formats.Add(WindowsWTUpdater());
                return formats;
            }
        }

        private static FormatSettings Log4jDE()
        {
            FormatSettings format = new FormatSettings(false);
            format.Name = "Log4j DE";
            format.addObj("Day", 2, @"");
            format.addObj("Month", 2, @"\.");
            format.addObj("Year", 2, @"\.");
            format.addObj("Hour", 2, @"\s");
            format.addObj("Minute", 2, @":");
            format.addObj("Second", 2, @":");
            format.addObj("Type", 1, @"\s\[");
            format.addObj("Package", 1, @"\]\W+?");
            format.addObj("Text", 0, @"\W-\W");
            return format;
        }

        private static FormatSettings Log4jEN()
        {
            FormatSettings format = new FormatSettings(false);
            format.Name = "Log4j EN";
            format.addObj("Year", 2, @"");
            format.addObj("Month", 2, @"-");
            format.addObj("Day", 2, @"-");            
            format.addObj("Hour", 2, @"\s");
            format.addObj("Minute", 2, @":");
            format.addObj("Second", 2, @":");
            format.addObj("Type", 1, @"\s\[");
            format.addObj("Package", 1, @"\]\W+?");
            format.addObj("Text", 0, @"\W-\W");
            return format;
        }

        private static FormatSettings WindowsUpdateLog()
        {
            FormatSettings format = new FormatSettings(false);
            format.Name = "WindowsUpdateLog";
            format.addObj("Year", 2, @"");
            format.addObj("Month", 2, @"-");
            format.addObj("Day", 2, @"-");
            format.addObj("Hour", 2, @"\t");
            format.addObj("Minute", 2, @":");
            format.addObj("Second", 2, @":");
            format.addObj("Text", 0, @".+?\t");
            return format;
        }

        private static FormatSettings WindowsWTUpdater()
        {
            FormatSettings format = new FormatSettings(false);
            format.Name = "WindowsWTUpdater";
            format.addObj("Day", 2, @"\w+?,\s");
            format.addObj("Month", 3, @"\s");
            format.addObj("Year", 2, @"\s");
            format.addObj("Hour", 2, @"\s");
            format.addObj("Minute", 2, @":");
            format.addObj("Second", 2, @":");
            format.addObj("Text", 0, @" : ");
            return format;
        }

        private static FormatSettings WindowsCEServicesCommunication()
        {
            FormatSettings format = new FormatSettings(false);
            format.Name = "WindowsCEServicesCommunication";
            format.addObj("Month", 2, @"");
            format.addObj("Day", 2, @"/");
            format.addObj("Year", 2, @"/");
            format.addObj("Hour", 2, @"\s");
            format.addObj("Minute", 2, @":");
            format.addObj("Second", 2, @":");
            format.addObj("Millisecond", 2, @".");
            format.addObj("Text", 0, @" - ");
            return format;
        }
    }
}
